﻿using System;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using SqEngine.AI;


using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Geometry;

using SqEngine;
using sqengine.PhysicObjects;
namespace sqengine.Components
{

    [Serializable]
    public class SqVersion
    {
        private string _name;
        private string _version;
        private Version _currentassembly;

        public string SqName { get { return SqEngineInfo._name; } }
        public string SqVerInfo { get { return SqEngineInfo._version; } }
        public string SqFullVersion { get { return SqEngineInfo._name + " " + SqEngine.SqEngineInfo._version; } }
        public Version SqAssembly { get { return SqEngineInfo._assembly; } set { _currentassembly = value; } }

    }
    [Serializable]
    public class CfgSave
    {
        private string _version = new SqVersion().SqFullVersion;
        private bool _fullscreen;
        private int _height;
        private int _width;
        private bool _antialiasing;
        private MultiSampleType _antialisingtype = MultiSampleType.None;
        private bool _bloomenabled;
        private string _playername;
        private string _playerlocation;
        private bool _showconsole;
        private bool _debugmode;
        private bool _introenabled;
        private string _introfile;
        private bool _tracelog;


        public string CfgVersion { get { return _version; } set { _version = value; } }
        public bool Fullscreen { get { return _fullscreen; } set { _fullscreen = value; } }
        public int ResolutionWidth { get { return _width; } set { _width = value; } }
        public int ResolutionHeight { get { return _height; } set { _height = value; } }
        public bool AntialiasingEnabled { get { return _antialiasing; } set { _antialiasing = value; } }
        public MultiSampleType AntialiasingType { get { return _antialisingtype; } set { _antialisingtype = value; } }
        public bool BloomEnabled { get { return _bloomenabled; } set { _bloomenabled = value; } }
        public string PlayerName { get { return _playername; } set { _playername = value; } }
        public string PlayerLocation { get { return _playerlocation; } set { _playerlocation = value; } }
        public bool ConsoleEnabled { get { return _showconsole; } set { _showconsole = value; } }
        public bool IntroEnabled { get { return _introenabled; } set { _introenabled = value; } }
        public string IntroFile { get { return _introfile; } set { _introfile = value; } }
        
        

        public bool DebugMode { get { return _debugmode; } set { _debugmode = value; } }
        public bool Tracelog { get { return _tracelog; } set { _tracelog = value; } }


        public CfgSave()
        {
            CfgVersion = new SqVersion().SqVerInfo;
        }
    }



    [Serializable]
    public class IntroContent
    {
        private List<PresentationMessage> _b_text = new List<PresentationMessage>();
        private string _background_song;
        public List<PresentationMessage> IntroText { get { return _b_text; } set { _b_text = value; } }
        public string BackgroundSong { get { return _background_song; } set { _background_song = value; } }

    }
    [Serializable]
    public class PresentationMessage
    {
        public string text = "";
        public string font;
        public PresentationType animantion;
        public double lifetime = 1000;
        public Vector2 position;
        public Color text_color;
        public bool shadow;
        public Color shadow_color;
        public int state = 0;
        public double fade_time = 1000;
        public bool background;
        public string backgroundtexture;
        public Vector2 backgroundpos;
        public int alpha = 0;
    }

    [Serializable]
    public class WeaponInfo
    {

        private string _WeaponModel;
        private string _WeaponTexture;

        private float _Weapon_scale;
        private float _Weapon_x_off;
        private float _Weapon_y_off;
        private float _Weapon_z_off;
        private string _WeaponName;
        private int _WeaponDamage;

        private string _WeaponShootSound;
        private string _WeaponOOAmmoSound;
        private int _Weapon_max_ammo;

        public string WeaponName { get { return _WeaponName; } set { _WeaponName = value; } }
        public string WeaponModel { get { return _WeaponModel; } set { _WeaponModel = value; } }
        public float Weapon_scale { get { return _Weapon_scale; } set { _Weapon_scale = value; } }
        public float Weapon_x_off { get { return _Weapon_x_off; } set { _Weapon_x_off = value; } }
        public float Weapon_y_off { get { return _Weapon_y_off; } set { _Weapon_y_off = value; } }
        public float Weapon_z_off { get { return _Weapon_z_off; } set { _Weapon_z_off = value; } }
        public string WeaponTexture { get { return _WeaponTexture; } set { _WeaponTexture = value; } }

        public string WeaponShootSound { get { return _WeaponShootSound; } set { _WeaponShootSound = value; } }
        public string WeaponOutOfAmmoSound { get { return _WeaponOOAmmoSound; } set { _WeaponOOAmmoSound = value; } }


        public int WeaponDamage { get { return _WeaponDamage; } set { _WeaponDamage = value; } }
        public int WeaponMaxAmmo { get { return _Weapon_max_ammo; } set { _Weapon_max_ammo = value; } }


        public WeaponInfo() { }

    }

    #region MediaPlayerObject
    [Serializable]
    public class MediaPlayerObject
    {
        public string Filename;
        public string Artist;
        public string Album;
        public string SongName;
        public double Duration;

    }
    #endregion

    [Serializable]
    public class BotInfo
    {
        private string _bot_name;
        private string _model_name;
        private WeaponInfo _weapon;
        private CBehaviourModel _cbehaviourmodel;



        private Vector3 _scale;
        private BotAudioInfo _bot_audio;
        private BotMessagesInfo _bot_messages;

        public string BotName { get { return _bot_name; } set { _bot_name = value; } }
        public string ModelName { get { return _model_name; } set { _model_name = value; } }
        public BotAudioInfo BotAudio { get { return _bot_audio; } set { _bot_audio = value; } }
        public BotMessagesInfo BotMessages { get { return _bot_messages; } set { _bot_messages = value; } }

        public WeaponInfo Weapon { get { return _weapon; } set { _weapon = value; } }
        public Vector3 Scale { get { return _scale; } set { _scale = value; } }
        public CBehaviourModel Behaviourmodel { get { return _cbehaviourmodel; } set { _cbehaviourmodel = value; } }
    }

    [Serializable]
    public class WorldBot
    {
        public string _bot_info;
        private Vector3 _position;
        private Vector3 _orientation;

        public string BotFile { get { return _bot_info; } set { _bot_info = value; } }
        public Vector3 Position { get { return _position; } set { _position = value; } }
        public Vector3 Orientation { get { return _orientation; } set { _orientation = value; } }

    }

    [Serializable]
    public class BotAudioInfo
    {

        private string _attack_snd;
        private string _random_snd;
        private string _difense_snd;
        private string _dead1_snd;
        private string _dead2_snd;
        private string _dead3_snd;
        private string _jump_snd;







        public string AttackSnd { get { return _attack_snd; } set { _attack_snd = value; } }
        public string RandomSnd { get { return _random_snd; } set { _random_snd = value; } }
        public string DifenseSnd { get { return _difense_snd; } set { _difense_snd = value; } }
        public string Dead1Snd { get { return _dead1_snd; } set { _dead1_snd = value; } }
        public string Dead2Snd { get { return _dead2_snd; } set { _dead2_snd = value; } }
        public string Dead3Snd { get { return _dead3_snd; } set { _dead3_snd = value; } }
        public string JumpSnd { get { return _jump_snd; } set { _jump_snd = value; } }



    }

    [Serializable]
    public class BotMessagesInfo
    {

        private List<string> _msgs_ondead;
        private List<string> _msgs_random;
        private List<string> _msgs_onbegin;
        private List<string> _msgs_onwin;
        private List<string> _msgs_onlose;


        public List<string> MessagesOnDead { get { return _msgs_ondead; } set { _msgs_ondead = value; } }
        public List<string> MessagesOnBegin { get { return _msgs_onbegin; } set { _msgs_onbegin = value; } }
        public List<string> MessagesOnWin { get { return _msgs_onwin; } set { _msgs_onwin = value; } }
        public List<string> MessagesOnLose { get { return _msgs_onlose; } set { _msgs_onlose = value; } }
        public List<string> MessagesRandom { get { return _msgs_random; } set { _msgs_random = value; } }

    }

    [Serializable]

    public class BasicWorldObject
    {

        private string _name;
        private string _objectfilename;
        private string _texture;

        public string Name { get { return _name; } set { _name = value; } }
        public string ObjectFilename { get { return _objectfilename; } set { _objectfilename = value; } }
        public string Texture { get { return _texture; } set { _texture = value; } }
    }


    [Serializable]
    public class WorldObject
    {
        private string _basicworldobject;
        private WorldObjectType _objecttype;

        private Vector3 _position;
        private Vector3 _rotation;
        private float _scale;
        private float _mass;
        private HybridDictionary _params = new HybridDictionary();

        public string BasicWorldObject { get { return _basicworldobject; } set { _basicworldobject = value; } }
        public WorldObjectType ObjectType { get { return _objecttype; } set { _objecttype = value; } }
        public HybridDictionary Params { get { return _params; } set { _params = value; } }
        public Vector3 Position { get { return _position; } set { _position = value; } }
        public Vector3 Rotation { get { return _rotation; } set { _rotation = value; } }
        public float Scale { get { return _scale; } set { _scale = value; } }
        public float Mass { get { return _mass; } set { _mass = value; } }



    }

    #region Map
    [Serializable]
    public class MapObject
    {
        private SqVersion _mapversion;
        private MapInfo _mapinfo = new MapInfo();
        private MapType _maptype;
        private string _terrain_model;
        private string _terrain_texture;
        private Vector3 _player_startposition;
        private float _skydome_time;

        private List<WorldObject> _worldobject = new List<WorldObject>();
        private List<WorldBot> _bots = new List<WorldBot>();


        public MapInfo MapInfo { get { return _mapinfo; } set { _mapinfo = value; } }
        public MapType MapType { get { return _maptype; } set { _maptype = value; } }
        public float SkydomeTime { get { return _skydome_time; } set { _skydome_time = value; } }
        public string TerrainModel { get { return _terrain_model; } set { _terrain_model = value; } }
        public string TerrainTexture { get { return _terrain_texture; } set { _terrain_texture = value; } }
        public Vector3 PlayerStartPosition { get { return _player_startposition; } set { _player_startposition = value; } }

        public List<WorldObject> WorldObjects { get { return _worldobject; } set { _worldobject = value; } }
        public List<WorldBot> Bots { get { return _bots; } set { _bots = value; } }

        public MapObject()
        {
            _mapversion = new SqVersion();

        }

    #endregion

    }


    #region InGameVars
    [Serializable]
    public class GameVars
    {
        SqVersion _sqver;
        HybridDictionary _vars;

        public HybridDictionary Vars { get { return _vars; } set { _vars = value; } }

        public GameVars()
        {
            _sqver = new SqVersion();
        }
    }


    #endregion


    #region MapInfo
    [Serializable]
    public class MapInfo
    {

        private string _mapname;
        private string _description;
        private string _author;
        private int _objectscount = 0;
        private int _botscount = 0;


        public string MapName { get { return _mapname; } set { _mapname = value; } }
        public string Author { get { return _author; } set { _author = value; } }
        public string Description { get { return _description; } set { _description = value; } }
        public int ObjectsCount { get { return _objectscount; } set { _objectscount = value; } }
        public int BotsCount { get { return _botscount; } set { _botscount = value; } }



    }
    #endregion

    #region MediaPlayerPl
    [Serializable]
    public class MediaPlayerPlaylist
    {
        private List<MediaPlayerObject> _mp3list = new List<MediaPlayerObject>();
        private string _directory;
        private int _mp3count;
        private DateTime _savetime;

        public List<MediaPlayerObject> MP3List { get { return _mp3list; } set { _mp3list = value; } }
        public string Directory { get { return _directory; } set { _directory = value; } }
        public int MP3Count { get { return _mp3count; } set { _mp3count = value; } }
        public DateTime SaveTime { get { return _savetime; } set { _savetime = value; } }

    }
    #endregion

}
